package com.shire.shire_interface;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@Aspect
public class ControllerPointCut {
    @Around("execution(public * com.shire.shire_interface.controller.*.*.*(..))" +
            "&& !execution(* com.shire.shire_interface.controller.kf.WebSocketController.*(..))")
    public Object aroundAdvice(ProceedingJoinPoint proceedingJoinPoint){
        Date date1 = new Date();
        try {//obj之前可以写目标方法执行前的逻辑
            Object obj = proceedingJoinPoint.proceed();//调用执行目标方法
            Date date2 = new Date();
//            System.out.println("++++ time cost :" + (date2.getTime() - date1.getTime()) + "  " + proceedingJoinPoint.getTarget().getClass() + "  " + proceedingJoinPoint.getSignature().getName());
            return obj;

        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }finally {
        }
        return null;
    }
}
